Within the IDL environment, a number of characters have special meanings.
The following table lists characters with special interpretations and states their functions in IDL. These characters are discussed further in the descriptions following the table.
Character |
Function |
! |
First character of system variable names and font-positioning commands |
' |
Delimit string constants |
Indicate part of octal or hex constant |
|
; |
Begin comment field |
$ |
Continue current command on the next line |
Issue operating system command if entered on a line by itself |
|
" |
Delimit string constants or precede octal constants |
. |
Indicate constant is floating point |
Start executive command |
|
& |
Separate multiple statements on one line |
: |
End label identifiers |
Separate start and end subscript ranges |
|
* |
Multiplication operator |
Array subscript range |
|
Pointer dereference (if in front of a valid pointer) |
|
@ |
Include file |
Execute IDL batch file |
|
? |
Invokes online help when entered at the IDL command line |
Part of the ?: ternary operator used in conditional expressions |
The exclamation point is the first character of names of IDL system-defined variables. System variables are predefined scalar variables of a fixed type. Their purpose is to override defaults for system procedures, to return status information, and to control the action of IDL.
The apostrophe delimits string literals and indicates part of an octal or hex constant.
The semicolon is the first character of the optional comment field of an IDL statement. All text on a line following a semicolon is ignored by IDL. A line can consist of a comment only or both a valid statement and a comment.
The dollar sign at the end of a line indicates that the current statement is continued on the following line. The dollar sign character can appear anywhere a space is legal except within a string constant or between a function name and the first open parenthesis. Any number of continuation lines are allowed.
When the $ character is entered as the first character after the IDL prompt, the rest of the line is sent to the operating system as a command. If $ is the only character present, an interactive subprocess is started. Under UNIX, IDL execution suspends until the new shell process terminates.
The quotation mark precedes octal numbers, which are always integers, and delimits string constants. Example: "100B is a byte constant equal to 64 base 10 and "Don’t drink the water" is a string constant.
The period or decimal point indicates in a numeric constant that the number is of floating-point or double-precision type. Example: 1.0 is a floating-point number. Also, in response to the IDL prompt, the period begins an executive command. For example,
.run myfile
causes IDL to compile the file myfile.pro. If myfile.pro contains a main program, the program also will be executed. In addition, the period precedes the name of a tag when referring to a field within a structure. For example, a reference to a tag called NAME in a structure stored in the variable A is A.NAME.
The ampersand separates multiple statements on one line. Statements can be combined until the maximum line length is reached. For example, the following line contains two statements:
I = 1 & PRINT, 'value:', I
The colon ends label identifiers. Labels can only be referenced by GOTO and ON_ERROR statements. The following line contains a statement with the label LOOP1.
LOOP1: X = 2.5
The colon also separates the starting and ending subscripts in subscript range specifiers. For example, A(3:6) designates elements three to six of the variable A.
The asterisk represents one of the following, depending on context:
The at sign is used both as an include character and to signal batch execution.
The at sign at the beginning of a line causes the IDL compiler to substitute the contents of the file whose name appears after the @ for the line. If the full path name is not specified after the @ symbol, IDL searches the current directory and the list of directories specified by the system variable !PATH.
For example, the line
@doit
when included in a file, causes the file doit.pro to be compiled in its place. (The suffix .pro is the default for IDL program files.) When the end of the file is reached, compilation resumes at the line after the @.
When IDL is running in interactive mode, a line beginning with the character @ is entered in response to the IDL prompt and the file is opened for batch input.
The question mark is used as follows:
; A shorter way of saying IF (a GT b) THEN z=a ELSE z=b:
z = (a GT b) ? a : b